package handle

//region Controller参数



//endregion

//region HTTP参数读取

// GetParamsToMap 通过Map获取所有Query参数
/*func GetParamsToMap(uValues url.Values) *shape.Map {

	fMap := shape.NewMap()

	for key, values := range uValues {
		if len(values) > 0 {
			fMap.Add(key, values[0])
		}
	}

	return fMap
}*/

// GetParamsToStruct 通过Struct获取所有Query参数
/*func GetParamsToStruct(uValues url.Values, queryParam IxBaseFormParam) error {
	val := reflect.ValueOf(queryParam).Elem()
	for i := 0; i < val.NumField(); i++ {
		field := val.Type().Field(i)
		queryTag := field.Tag.Get("query")
		if queryTag == "" {
			queryTag = strings.ToLower(field.Name)
		}
		value := uValues.Get(queryTag)
		if value != "" {
			if err := reflectx.SetField(val, field.Name, value); err != nil {
				return err
			}
		}
	}
	return nil
}*/

//endregion

//region Request结构体定义

//r.PostForm
//r.PostFormValue("className")
//r.Form
//r.FormValue("className")
//r.URL.Query()
//r.URL.Query().Get("className")
//r.GetBody
//r.MultipartForm
//r.Header.Get("User-Agent")
//r.Cookies()
//r.Cookie("sKey")

/*type BlendRequest struct {
	*BlendHttp
	*shape.Map
	*vault.QueryParam
}

func NewBlendRequest(bHttp *BlendHttp, reqParam bean.IxBaseReqParam) *BlendRequest {

	_ = bHttp.R.ParseForm()
	_ = bHttp.R.ParseMultipartForm(math.MaxInt64)
	if !reqParam.InitParam(bHttp.W, bHttp.R) {
		http.Error(bHttp.W, "参数校验异常", http.StatusServiceUnavailable)
		return nil
	}

	paramMap := GetParamsToMap(bHttp.R.Form)

	testParam := new(BlendRequest)
	testParam.BlendHttp = bHttp
	testParam.Map = paramMap
	testParam.QueryParam = vault.NewQueryParam(paramMap)

	return testParam
}

func GetDefaultBlendRequest(args []*BlendRequest) *BlendRequest {
	return sugar.GetDefaultArgs(args, func() *BlendRequest {
		return &BlendRequest{
			Map: shape.NewMap(),
		}
	})
}*/

//endregion
